$(function () {
	$(".close_ico").on("click", function () {
		$(".safe_warm").css("display", "none")
	})
	$(".site_nav .site_nav_bd ul li #headerAllProvince li a").on("click",function () {
		$("#usersProvince").html($(this).html());
		
	})
	$(".province_box").on("mouseover",function (){
		$(this).css("background","#fff");
	    $("#headerAllProvince").css("display","block");
	})
	
	$("#headerAllProvince").on("mouseleave",function (){
		$(this).css("display","none");
		$(".province_box").css("background","none");
	})
	$("#mynet").on("mouseover",function (){
	    $("#my1YaoWang").css("display","block");
	})
	$("#my1YaoWang").on("mouseleave",function (){
	    $(this).css("display","none");
	})
	$("#iphone").on("mouseover",function (){
		$(this).css("background","white");
		$("#menu_bd_app").css("display","block");
	})
	$("#menu_bd_app").on("mouseleave",function (){
	    $(this).css("display","none");
	    $("#iphone").css("background","none");
	})
	$("#sortKindsnoe").on("mouseover",function (){
	     $(this).css("left","5px");
		$("#category1").css("display","block");
	})
	
	$("#category1").on("mouseleave",function (){
	    $(this).css("display","none");
	})
	
	$("#sortKindstwo").on("mouseover",function () {
		$("#category2").css("display","block");
	})
	$("#category2").on("mouseleave",function (){
	    $(this).css("display","none");
	})
	$("#sortKindsthree").on("mouseover",function () {
		$("#category3").css("display","block");
	})
	$("#category3").on("mouseleave",function (){
		$(this).css("display","none");
	})
	
	$("#sortKindsfour").on("mouseover",function () {
		$("#category4").css("display","block");
	})
	$("#category4").on("mouseleave",function (){
		$(this).css("display","none");
	})
	
	//页面左侧楼梯
	var bool  = true;//判断是否是由点击事件造成的滚动
	var  $loutiNav = $('#loutiNav');
	//给楼梯的li绑定事件
	$loutiNav.find('li').click(function(){
		bool = false;
		//this
		//$(this).index()
		$(this).find('span').addClass('active').parent().siblings().find('span').removeClass('active')
		//滚动的高度
		var top  =$('.index_floor').eq( $(this).index() ).offset().top;
		
		//给滚动条添加动画
//					$(window).animate({
//						'scrollTop': top
//					})
		
		$('html,body').animate({
			'scrollTop': top
		},function(){
			//动画结束 改回bool值  让滚动事件正常触发
			bool = true;
		})
		
		
		
	})
	
	$(window).scroll(function(){
		
		//判断是否是由点击楼梯造成的滚动
		if(bool){
			//当前的滚动高度
			var current = $(window).scrollTop();
			var  index ;
			//对楼层进行遍历
			for(var i=0;i<$('.index_floor').length;i++){
				
				if(current >= $($('.index_floor')[i]).offset().top){
					index = i;
				}
			}
			console.log(index);
			
			//修改楼梯的样式
			$('#loutiNav').find("li").eq(index).find('span').addClass('active').parent().siblings().find('span').removeClass('active');
		}
		
	})
	
	
	
	
	//遍历页面中所有的图片
	$.ajax({
		url:"../js/indeximg.json",
		async:"true",
		dataType:"json",
		success:function (res){
			for (var i=0; i < res.bannerimg.length;i++) {
				$(".main_body .specialAds a img").eq(i).attr("src",res.bannerimg[i]);
			}
			for (var i=0; i < res.floorOne.length;i++) {
			    $(".in_floor_r").find("img").eq(i).attr("src",res.floorOne[i]);
			}
			for (var i=0; i < res.floorTwo.length;i++) {
				$("#floorTwo").find("img").eq(i).attr("src",res.floorTwo[i]);
			}
			for (var i=0; i < res.floorThree.length;i++) {
				$("#floor3border").find("img").eq(i).attr("src",res.floorThree[i]);
			}
			for (var i=0; i < res.floorFour.length;i++) {
			    $("#floor4border").find("img").eq(i).attr("src",res.floorFour[i]);
			}
			for (var i=0; i < res.floorFive.length;i++) {
			    $("#floor5border").find("img").eq(i).attr("src",res.floorFive[i]);
			}
			for (var i=0; i < res.floorSix.length;i++) {
			    $("#floor6border").find("img").eq(i).attr("src",res.floorSix[i]);
			}
			for (var i=0; i < res.floorSeven.length;i++) {
			    $("#floor7border").find("img").eq(i).attr("src",res.floorSeven[i]);
			}
			for (var i=0; i < res.floorEight.length;i++) {
			    $("#floor8border").find("img").eq(i).attr("src",res.floorEight[i]);
			}
			for (var i=0; i < res.floorNine.length;i++) {
			    $("#floor9border").find("img").eq(i).attr("src",res.floorNine[i]);
			}
		}
	})
	
});